import { Component, OnInit } from '@angular/core';

import { Hotel } from '../../domain/hotel';

import { HotelService } from '../../service/hotel.service';

declare var layui;
@Component({
  selector: 'app-hotel-detail',
  templateUrl: './hotel-detail.component.html',
  styleUrls: ['./hotel-detail.component.css'],
  providers: [HotelService]
})
export class HotelDetailComponent implements OnInit {

  hotel: Hotel;

  constructor(
    private hotelService: HotelService,
  ) { }

  ngOnInit() {
    layui.use('laydate', function () {
      var laydate = layui.laydate;

      //执行一个laydate实例
      //日期选择器
      laydate.render({
        elem: '#date',
      });

      laydate.render({
        elem: '#open'
        , type: 'time'
      });

      laydate.render({
        elem: '#close'
        , type: 'time'
      });
    });

    this.hotelService.getHotelById(1)
      .then(res => this.hotel = res);
  }

  updateHotel(): void {
    this.hotelService.updateHotel(this.hotel)
      .then(() => {
        location.reload();
      })
  }

  reset(): void {
    location.reload();
  }



}
